import { useSiteStore } from '@/stores/site'
import { buildColumns } from '@/utils'
export default function useTableColumn() {
  const router = useRouter()
  const columns = computed(() =>
    buildColumns([
      {
        title: '站点',
        dataIndex: 'domain',
        cellClass: 'link',
        width: 184,
        slotName: 'domain',
        format: 'copy',
        clickFn: (row) => {
          useSiteStore().setSiteInfo(row)
          router.push({
            name: 'SiteConfig',
            params: { id: row?.id }
          })
        }
      },
      {
        title: '区域',
        dataIndex: 'region_info',
        cellClass: 'edit-icon',
        width: 184,
        slotName: 'region_info'
      },
      {
        title: '分组',
        dataIndex: 'group_info',
        width: 184,
        slotName: 'group_info'
      },
      {
        title: 'CNAME',
        dataIndex: 'resolve_info1',
        width: 240,
        slotName: 'resolve_info1'
      },
      {
        title: '接入状态',
        dataIndex: 'resolve_info',
        width: 124,
        slotName: 'resolve_info'
      },
      {
        title: 'HTTPS',
        dataIndex: 'https',
        width: 95,
        slotName: 'https'
      },
      {
        title: '添加时间',
        dataIndex: 'created_at',
        width: 184,
        format: 'date-time',
        sortable: sortableSettings
      },
      {
        title: '备注',
        dataIndex: 'remark',
        width: 184,
        slotName: 'remark'
      },
      {
        title: '启用状态',
        dataIndex: 'status',
        width: 100,
        slotName: 'status'
      },
      {
        title: '操作',
        slotName: 'action',
        width: 120,
        cellClass: 'actions-cell',
        fixed: 'right'
      }
    ])
  )
  return {
    columns
  }
}
